---
category: Date Time
created: '2020-04-19'
title: Get the number of days in given month
updated: '2021-10-13'
---

**JavaScript version**

```js daysInMonth.js
// `month` is zero-based index
const daysInMonth = (month, year) => new Date(year, month, 0).getDate();
```

**TypeScript version**

```ts daysInMonth.ts
const daysInMonth = (month: number, year: number): number => new Date(year, month, 0).getDate();
```
